<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="id" name="id" value="${topic.id!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">题目标题</label>
              <div class="layui-input-block">
                  <input type="text" id="topicTitle" name="topicTitle" value="${topic.topicTitle!}"  autocomplete="off" placeholder="请输入题目标题"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">题目类型</label>
              <div class="layui-input-block">
                  <input type="text" id="topicType" name="topicType" value="${topic.topicType!}"  autocomplete="off" placeholder="请输入题目类型"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">1 默认/ 2 必答</label>
              <div class="layui-input-block">
                  <input type="text" id="topicAnswer" name="topicAnswer" value="${topic.topicAnswer!}"  autocomplete="off" placeholder="请输入1 默认/ 2 必答"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">题目排序</label>
              <div class="layui-input-block">
                  <input type="text" id="topicSort" name="topicSort" value="${topic.topicSort!}"  autocomplete="off" placeholder="请输入题目排序"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">跳过的题目id , 分割</label>
              <div class="layui-input-block">
                  <input type="text" id="topicSkip" name="topicSkip" value="${topic.topicSkip!}"  autocomplete="off" placeholder="请输入跳过的题目id , 分割"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">问卷id</label>
              <div class="layui-input-block">
                  <input type="text" id="questionnaireId" name="questionnaireId" value="${topic.questionnaireId!}"  autocomplete="off" placeholder="请输入问卷id"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">0 一行显示1个/1行显示2个/2下拉</label>
              <div class="layui-input-block">
                  <input type="text" id="topicRow" name="topicRow" value="${topic.topicRow!}"  autocomplete="off" placeholder="请输入0 一行显示1个/1行显示2个/2下拉"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">显示条件(上面矩阵单选的答案为条件)</label>
              <div class="layui-input-block">
                  <input type="text" id="topicCondition" name="topicCondition" value="${topic.topicCondition!}"  autocomplete="off" placeholder="请输入显示条件(上面矩阵单选的答案为条件)"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">多选题最少选项个数</label>
              <div class="layui-input-block">
                  <input type="text" id="topicLeast" name="topicLeast" value="${topic.topicLeast!}"  autocomplete="off" placeholder="请输入多选题最少选项个数"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">多选题最多选项个数</label>
              <div class="layui-input-block">
                  <input type="text" id="topicMost" name="topicMost" value="${topic.topicMost!}"  autocomplete="off" placeholder="请输入多选题最多选项个数"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">引用其他问题的选项</label>
              <div class="layui-input-block">
                  <input type="text" id="topicQuoteId" name="topicQuoteId" value="${topic.topicQuoteId!}"  autocomplete="off" placeholder="请输入引用其他问题的选项"
                         class="layui-input">
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         id:$("#id").val(),
                         topicTitle:$("#topicTitle").val(),
                         topicType:$("#topicType").val(),
                         topicAnswer:$("#topicAnswer").val(),
                         topicSort:$("#topicSort").val(),
                         topicSkip:$("#topicSkip").val(),
                         questionnaireId:$("#questionnaireId").val(),
                         topicRow:$("#topicRow").val(),
                         topicCondition:$("#topicCondition").val(),
                         topicLeast:$("#topicLeast").val(),
                         topicMost:$("#topicMost").val(),
                           topicQuoteId:$("#topicQuoteId").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/star/topic/admin/editTopic",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/star/topic/admin/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#topicTitle").val().length<1){
                       layer.msg("请输入题目标题");
                       return false;
                   }
                   if($("#topicType").val().length<1){
                       layer.msg("请输入题目类型");
                       return false;
                   }
                   if($("#topicAnswer").val().length<1){
                       layer.msg("请输入1 默认/ 2 必答");
                       return false;
                   }
                   if($("#topicSort").val().length<1){
                       layer.msg("请输入题目排序");
                       return false;
                   }
                   if($("#topicSkip").val().length<1){
                       layer.msg("请输入跳过的题目id , 分割");
                       return false;
                   }
                   if($("#questionnaireId").val().length<1){
                       layer.msg("请输入问卷id");
                       return false;
                   }
                   if($("#topicRow").val().length<1){
                       layer.msg("请输入0 一行显示1个/1行显示2个/2下拉");
                       return false;
                   }
                   if($("#topicCondition").val().length<1){
                       layer.msg("请输入显示条件(上面矩阵单选的答案为条件)");
                       return false;
                   }
                   if($("#topicLeast").val().length<1){
                       layer.msg("请输入多选题最少选项个数");
                       return false;
                   }
                   if($("#topicMost").val().length<1){
                       layer.msg("请输入多选题最多选项个数");
                       return false;
                   }
                   if($("#topicQuoteId").val().length<1){
                       layer.msg("请输入引用其他问题的选项");
                       return false;
                   }
        }
    });

</script>
</body>
</html>